﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;

namespace Batty
{
    public class Field
    {
        private Pondhawk game;
        private Model model;
        private Vector3 position = new Vector3(0, 0, 0);

        public Field(Pondhawk game)
        {

            this.game = game;
          
        }

        public void LoadContent(ContentManager content)
        {
            model = content.Load<Model>("GrassField2");
        }

        public void Draw(GraphicsDeviceManager graphics, GameTime gameTime)
        {
            Matrix transform = Matrix.CreateTranslation(position)*Matrix.CreateScale(10);
            System.Diagnostics.Trace.WriteLine("FieldPositon" + position.X.ToString() + "  " + position.Y.ToString() + "   " + position.Z.ToString());
            DrawModel(graphics, model, transform);
           // DrawModel(graphics, model, Matrix.Identity);


        }

        private void DrawModel(GraphicsDeviceManager graphics, Model model, Matrix world)
        {
            Matrix[] transforms = new Matrix[model.Bones.Count];
            model.CopyAbsoluteBoneTransformsTo(transforms);

            foreach (ModelMesh mesh in model.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.EnableDefaultLighting();
                    effect.World = transforms[mesh.ParentBone.Index] * world;
                    effect.View = game.Camera.View;
                    effect.Projection = game.Camera.Projection;
                }
                mesh.Draw();
            }
        }
    }

       
}
